package main

import (
	"fmt"
	"math"
)

func solution(S string, T string) int {
	// PLEASE DO NOT MODIFY THE FUNCTION SIGNATURE
	// write code here
	n := len(S)
	m := len(T)
	ans := float64(n)
	cnt := 0

	for i := 0; i < n && i < m; i++ {
		if S[i] != T[i] {
			cnt++
		}
		delNum := cnt + n - 1 - i
		ans = math.Min(float64(ans), float64(delNum))
	}

	return int(ans)
}

func main() {
	fmt.Println(solution("aba", "abb") == 1)
	fmt.Println(solution("abcd", "efg") == 4)
	fmt.Println(solution("xyz", "xy") == 1)
	fmt.Println(solution("hello", "helloworld") == 0)
	fmt.Println(solution("same", "same") == 0)
}

